#!/bin/bash

ROOT_PATH=`cd $(dirname "$0")/../; pwd`

OUT=${ROOT_PATH}/out/target/product/sabresd_6dq

UBOOT=${OUT}/u-boot-6q.bin
BOOTIMG=${OUT}/boot.img
SYSTEMIMG=${OUT}/system.img
RECOVERYIMG=${OUT}/recovery.img

NODE=/dev/${1}

if [ ! -b ${NODE} ]; then
	echo ${NODE} is not a block file!
	exit
fi

${ROOT_PATH}/device/fsl/common/tools/fsl-sdcard-partition.sh ${NODE}

dd if=${UBOOT} of=${NODE} bs=1K skip=1 seek=1; sync
dd if=/dev/zero of=${NODE}  bs=512 seek=1636 count=16; sync
dd if=${BOOTIMG} of=${NODE}1; sync
dd if=${SYSTEMIMG} of=${NODE}5; sync
dd if=${RECOVERYIMG} of=${NODE}2; sync

